package com.JZ.QM.service.impl;

import com.JZ.QM.common.dao.CommentDetailDao;
import com.JZ.QM.common.dao.UserCommentDao;
import com.JZ.QM.common.entity.CommentDetailEntity;
import com.JZ.QM.common.entity.UserCollectEntity;
import com.JZ.QM.common.entity.UserCommentEntity;
import com.JZ.QM.common.utils.PageUtils;
import com.JZ.QM.common.utils.Query;
import com.JZ.QM.service.UserCommentService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Map;

/**
 * @author: cyc
 * @email cyc@gmail.com
 * @date: 2020/7/6 9:35
 */
@Service()
public class UserCommentServiceImpl extends ServiceImpl<UserCommentDao, UserCommentEntity> implements UserCommentService {

    @Resource
    CommentDetailDao commentDetailDao;

    public PageUtils queryPage(Map<String, Object> params) throws Exception {
        IPage<UserCommentEntity> page = this.page(
                new Query<UserCommentEntity>().getPage(params),
                new QueryWrapper<UserCommentEntity>()
        );

        return new PageUtils(page);
    }

    /**
     *返佣组=组合内的所有的评论信息
     * @param comBaseId 组合id
     * @return
     */
    @Override
    public ArrayList<CommentDetailEntity> getAllCommentDetails(Long comBaseId) {
        //组合的评论列表
        ArrayList<CommentDetailEntity> commentDetailEntities=new ArrayList<>();

        //获取评论信息列表
        commentDetailEntities= commentDetailDao.getAllCommentDetails(comBaseId);
        return commentDetailEntities;
    }
}
